package com.CI.ViewAllBook.Commands
{
	import com.CI.ViewAllBook.Business.ViewDelegate;
	import com.CI.ViewAllBook.Control.ViewBookPublishedEvents;
	import com.CI.ViewAllBook.Control.ViewEbookEvents;
	import com.adobe.cairngorm.business.Responder;
	import com.adobe.cairngorm.commands.Command;

	
	public class ViewCommands implements Command,Responder
	{
		public function ViewCommands()  
		{
		}
		
		public function execute(event : CairngormEvent) : void
		{
			var str : String = event.type;
			
			if(str == 'viewAllBookPublished')
			{
				var viewBookEvent : ViewBookPublishedEvents = ViewBookPublishedEvents(event);
				getDelegate.sendObject(viewBookEvent.bookPublished);
			}
			else
			{
				var viewEbookEvent : ViewEbookEvents = ViewEbookEvents(event);
				getDelegate.sendObject(viewEbookEvent.ebook);
			}
		}
		
		public function onFault(event : *=null) : void
		{
			
		}
		
		public function onResult(event : *=null) : void
		{
			
		}
		
		protected function get getDelegate(): ViewDelegate
		{
			return new ViewDelegate(this);
		}
	}
}